<template>
  <view v-if="visible" class="loading-overlay">
    <view class="loading-content">
      <nut-loading :type="type" :color="color" />
      <view v-if="text" class="loading-text">{{ text }}</view>
    </view>
  </view>
</template>

<script setup lang="ts">
interface Props {
  visible?: boolean
  text?: string
  type?: 'circular' | 'spinner'
  color?: string
}

withDefaults(defineProps<Props>(), {
  visible: false,
  text: '加载中...',
  type: 'circular',
  color: 'var(--color-primary)'
})
</script>

<style lang="scss" scoped>
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.loading-text {
  font-size: 14px;
  color: #666;
}
</style> 